package com.cyyz.tai.controller;

import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.cyyz.tai.model.DashPoint;
import com.cyyz.tai.model.DashStats;
import com.cyyz.tai.model.IndexData;
import com.cyyz.tai.model.LineLossStats;
import com.cyyz.tai.model.NetworkConstruction;
import com.cyyz.tai.model.QueryBean;
import com.cyyz.tai.model.ResultBean;
import com.cyyz.tai.model.SupplyPowerQuality;
import com.cyyz.tai.service.DashPointService;
import com.cyyz.tai.service.DashStatsService;
import com.google.common.collect.Lists;
import com.vteba.utils.id.ObjectId;
import jakarta.inject.Inject;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 空港项目demo首页数据控制器
 *
 * @author 尹雷
 */
@RestController
@RequestMapping(value = "/dashboard")
public class DashboardController {
    private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);

    @Inject
    private DashPointService dashPointService;
    @Inject
    private DashStatsService dashStatsService;

    /**
     * 首页指标
     * @return
     */
    @RequestMapping("/mainIndex")
    public Object mainIndex(@RequestBody QueryBean queryBean) {
        ResultBean bean = new ResultBean();

        Map<String, Object> result = new HashMap<>();

        String type = queryBean.getType();
        if ("2".equals(type)) {
            // 1、服务情况
            Map<String, Object> service = new HashMap<>();

            IndexData current = new IndexData();
            current.setCaijiChenggongLv(99D);
            current.setDianFeiHuiShouLv(99.96);
            current.setYewuShouliShuliang(102);

            IndexData year = new IndexData();
            year.setCaijiChenggongLv(99.69D);
            year.setDianFeiHuiShouLv(99.88);
            year.setYewuShouliShuliang(2362);

            service.put("current", current);
            service.put("year", year);

            result.put("service", service);

            // 2、用户分布
            Map<String, Object> user = new HashMap<>();

            IndexData userCurrent = new IndexData();
            userCurrent.setJuminYonghuShu(699);
            userCurrent.setShangyeYonghuShu(289);
            userCurrent.setGongyeYonghuShu(156);
            userCurrent.setNongyeShengchanYonghuShu(82);
            userCurrent.setGongGongShiyeDanweiShu(109);

            IndexData userYear = new IndexData();
            userYear.setJuminYonghuShu(8909);
            userYear.setShangyeYonghuShu(2289);
            userYear.setGongyeYonghuShu(2156);
            userYear.setNongyeShengchanYonghuShu(282);
            userYear.setGongGongShiyeDanweiShu(1809);

            user.put("current", userCurrent);
            user.put("year", userYear);

            result.put("user", user);

            bean.setCode(1);
            bean.setData(result);
        } else {
            // 1、供电质量
            Map<String, SupplyPowerQuality> supplyPowerQuality = new HashMap<>();
            // 当前
            SupplyPowerQuality currentQuality = new SupplyPowerQuality();
            currentQuality.setPassRate(98.78D);
            currentQuality.setReliability(99.998D);
            supplyPowerQuality.put("current", currentQuality);
            // 本年累计
            SupplyPowerQuality yearQuality = new SupplyPowerQuality();
            yearQuality.setPassRate(99.26D);
            yearQuality.setReliability(99.398D);
            supplyPowerQuality.put("year", yearQuality);

            // 2、配网建设
            Map<String, NetworkConstruction> networkConstruction = new HashMap<>();

            NetworkConstruction currentNetwork = new NetworkConstruction();
            currentNetwork.setProjectCount(28);
            currentNetwork.setAutoRunIndex(98.2D);
            currentNetwork.setBudgetCompleteRate(95.35);
            currentNetwork.setConversionRate(95.7);

            networkConstruction.put("current", currentNetwork);

            NetworkConstruction yearNetwork = new NetworkConstruction();
            yearNetwork.setProjectCount(79);
            yearNetwork.setAutoRunIndex(97.89D);
            yearNetwork.setBudgetCompleteRate(96.77);
            yearNetwork.setConversionRate(98.4);
            networkConstruction.put("year", yearNetwork);

            // 3、线损情况
            Map<String, LineLossStats> lineLossStats = new HashMap<>();
            LineLossStats currentLoss = new LineLossStats();
            currentLoss.setAverageDayLineLossRate(1.13);
            currentLoss.setTotalLineLossRate(1.08);
            currentLoss.setComplianceRate(99.34);
            currentLoss.setEconomicStats(98.26);

            lineLossStats.put("current", currentLoss);

            LineLossStats yearLoss = new LineLossStats();
            yearLoss.setAverageDayLineLossRate(1.22);
            yearLoss.setTotalLineLossRate(1.07);
            yearLoss.setComplianceRate(98.69);
            yearLoss.setEconomicStats(99.63);
            lineLossStats.put("year", yearLoss);

            result.put("supplyPowerQuality", supplyPowerQuality);
            result.put("networkConstruction", networkConstruction);
            result.put("lineLossStats", lineLossStats);

            bean.setCode(1);
            bean.setData(result);

            String prettyJson = JSON.toJSONString(bean, JSONWriter.Feature.PrettyFormat);

            LOGGER.info(prettyJson);
        }

        return bean;
    }

    /**
     * 快速分析
     * @return
     */
    @RequestMapping("/fastAnalysis")
    public Object fastAnalysis(@RequestBody QueryBean queryBean) {
        ResultBean bean = new ResultBean();
        String type = queryBean.getType();

        if ("2".equals(type)) {
            // 这里是工单次数
            int[] data = NumberUtil.generateRandomNumber(20, 150, 7);
            // String str = StringUtils.join(data, ",");
            String str = Arrays.toString(data);

            StringBuilder sb = new StringBuilder("{ xAxis:['一月', '二月', '三月', '四月', '五月', '六月'],");
            sb.append("series:[");
            sb.append(str);
            sb.append("]}");

            JSONObject jsonObject = JSON.parseObject(sb.toString(), JSONReader.Feature.AllowUnQuotedFieldNames);
            bean.setCode(1);
            bean.setData(jsonObject);

        } else {
            // String json = """
            //     {
            //             xAxis:['一月', '二月', '三月', '四月', '五月', '六月'],
            //             series:[
            //               [5, 20, 36, 10, 10, 20, 20],
            //               [15, 0, 26, 10, 30, 10, 90]
            //             ]
            //           }
            //     """;

            int[] data = NumberUtil.generateRandomNumber(2, 100, 7);
            int[] data2 = NumberUtil.generateRandomNumber(2, 100, 7);
            // String str1 = StringUtils.join(data, ",");
            // String str2 = StringUtils.join(data2, ",");
            String str1 = Arrays.toString(data);
            String str2 = Arrays.toString(data2);

            StringBuilder sb = new StringBuilder("{ xAxis:['一月', '二月', '三月', '四月', '五月', '六月'],");
            sb.append("series:[");
            sb.append(str1).append(",");
            sb.append(str2);
            sb.append("]}");

            String json = sb.toString();

            JSONObject jsonObject = JSON.parseObject(json, JSONReader.Feature.AllowUnQuotedFieldNames);
            LOGGER.info("Parse json success, js=[{}]", jsonObject);

            bean.setCode(1);
            bean.setData(jsonObject);

            String prettyJson = JSON.toJSONString(bean, JSONWriter.Feature.PrettyFormat);

            LOGGER.info(prettyJson);
        }

        return bean;
    }

    /**
     * 监测分析
     * @return
     */
    @RequestMapping("/monitorAnalysis")
    public Object monitorAnalysis(@RequestBody QueryBean queryBean) {
        ResultBean result = new ResultBean();

        String type = queryBean.getType();

        List<DashStats> dashStatsList;

        // 第二页的检测分析
        if ("2".equals(type)) {
            dashStatsList = dashStatsService.queryCountList(2);
        } else { // 第一页的检测分析
            dashStatsList = dashStatsService.queryCountList(1);
        }
        if (CollectionUtils.isEmpty(dashStatsList)) {
            result.setCode(2);
            result.setMessage("没有查询到检测分析");
            LOGGER.error("没有查询到检测分析");
        } else {
            result.setCode(1);

            int size = dashStatsList.size();
            int[] weekNew = NumberUtil.generateRandomNumber(1, 11, size);
            for (int i = 0; i < size; i++) {
                DashStats dashStats = dashStatsList.get(i);
                int week = weekNew[i];
                dashStats.setValue2((double) week);
            }
            result.setData(dashStatsList);
        }

        String prettyJson = JSON.toJSONString(result, JSONWriter.Feature.PrettyFormat);
        LOGGER.info(prettyJson);

        return result;
    }

    /**
     * 地图路径
     * @return
     */
    @RequestMapping("/mapPath")
    public Object mapPath() {
        ResultBean resultBean = new ResultBean();
        // initPoint();
        DashPoint query = new DashPoint();
        List<DashPoint> pointList = dashPointService.queryList(query);

        resultBean.setData(pointList);
        resultBean.setCode(1);

        return resultBean;
    }

    private void initPoint() {
        File file = new File("E:\\工作\\空港\\map_json.ts");

        try {
            FileInputStream fis = new FileInputStream(file);
            byte[] jsonBytes = IOUtils.toByteArray(fis);
            // json 字段没有引号括起来，出错。使用jackson是OK的
            List<DashPoint> jsonArray = JSON.parseArray(jsonBytes, DashPoint.class, JSONReader.Feature.AllowUnQuotedFieldNames);
            // Jackson默认不允许尾随逗号，fastjson默认是允许的。已经配置添加允许尾随逗号
            // List<DashPoint> jsonArray = JacksonUtils.fromJsonList(jsonBytes, DashPoint.class);
            for (DashPoint point : jsonArray) {
                point.setId(ObjectId.get().toString());
                // point.setCreateDate(new Date());
                // point.setStates(1);
                // dashPointService.save(point);
            }
            IOUtils.closeQuietly(fis);
        } catch (Exception e) {
            LOGGER.error("解析json出错", e);
        }
    }

    /**
     * 业务清单
     *
     * @param queryBean
     * @return
     */
    @RequestMapping("/detailList")
    public Object detailList(@RequestBody QueryBean queryBean) {
        ResultBean result = new ResultBean();

        // 这个两个方法是构造数据的
        // buildDetailData();
        // buildUserDetailData();

        DashStats dashStats = new DashStats();
        dashStats.setPointId(queryBean.getId());
        dashStats.setDefectType(queryBean.getType());
        dashStats.setStates(queryBean.getStates());
        dashStats.setMountDevice(queryBean.getMountDevice());

        List<DashStats> dashStatsList = dashStatsService.queryList(dashStats);

        if (CollectionUtils.isEmpty(dashStatsList)) {
            result.setCode(2);
            result.setMessage("没有查询到明细数据");
        } else {
            result.setCode(1);
            result.setData(dashStatsList);
        }

        return result;
    }

    /**
     * 点击列表的上报人详情
     *
     * @param queryBean
     * @return
     */
    @RequestMapping("/userDetail")
    public ResultBean userDetail(@RequestBody QueryBean queryBean) {
        ResultBean bean = new ResultBean();

        String id = queryBean.getId();
        DashStats dashStats = dashStatsService.get(id);

        List<Map<String, String>> dataList = new ArrayList<>();

        Map<String, String> data1 = new HashMap<>();
        data1.put("name", dashStats.getReportPerson());
        data1.put("url", "/static/1.jpeg");

        Map<String, String> data2 = new HashMap<>();
        data2.put("name", "赵琳");
        data2.put("url", "/static/2.jpeg");

        Map<String, String> data3 = new HashMap<>();
        data3.put("name", "王肖战");
        data3.put("url", "/static/3.jpeg");

        dataList.add(data1);
        dataList.add(data2);
        dataList.add(data3);

        bean.setCode(1);
        bean.setData(dataList);

        return bean;
    }

    /**
     * 挂载设备详情
     *
     * @param dashStats 参数，挂载设备类型不能为空
     * @return
     */
    @RequestMapping("/mountDeviceDetail")
    public ResultBean mountDeviceDetail(@RequestBody DashStats dashStats) {
        ResultBean result = new ResultBean();

        DashStats queryStats = new DashStats();
        queryStats.setMountDevice(dashStats.getMountDevice());
        queryStats.setStates(dashStats.getStates());
        // queryStats.setMountDevice("高铁");
        // queryStats.setStates(1);

        List<DashStats> dashStatsList = dashStatsService.queryList(queryStats);

        Set<String> pointIdSet = new HashSet<>();
        if (CollectionUtils.isNotEmpty(dashStatsList)) {
            dashStatsList.forEach(it -> pointIdSet.add(it.getPointId()));
        }

        String hql = "select d from DashPoint d where d.id in (?1)";
        List<DashPoint> dashPointList = dashPointService.queryListHQL(hql, Lists.newArrayList(pointIdSet));

        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("point", dashPointList);
        dataMap.put("list", dashStatsList);

        result.setCode(1);
        result.setData(dataMap);

        return result;
    }

    /**
     * 挂载设备列表
     *
     * @param dashStats 必填参数states
     * @return
     */
    @RequestMapping("/mountDeviceList")
    public ResultBean mountDeviceList(@RequestBody DashStats dashStats) {
        ResultBean result = new ResultBean();

        Integer states = dashStats.getStates();
        if (states == null || states == 0) {
            result.setCode(2);
            result.setMessage("参数states不能为空");
            return result;
        }

        String sql = "SELECT count(*) value1, mount_device FROM dash_stats WHERE states = ? GROUP BY mount_device";
        List<DashStats> dashStatsList = dashStatsService.queryListSQL(sql, dashStats.getStates());

        result.setCode(1);
        result.setData(dashStatsList);

        return result;
    }

    /**
     * 台区画像，台区详情
     *
     * @param dashPoint
     * @return
     */
    @RequestMapping("/taiquDetail")
    public ResultBean taiquDetail(DashPoint dashPoint) {
        ResultBean result = new ResultBean();

        String id = dashPoint.getId();

        DashPoint point = dashPointService.get(id);

        Map<String, Object> gongDianKeKaoXing = new HashMap<>();

        Map<String, Object> taiQuYiChang = new HashMap<>();
        Map<String, Object> taiQuTongJi = new HashMap<>();
        Map<String, Object> zongHeXianSunLv = new HashMap<>();
        Map<String, Object> fuHeQingKuang = new HashMap<>();
        Map<String, Object> gongDanQingKuang = new HashMap<>();

        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("gongDianKeKaoXing", gongDianKeKaoXing);
        dataMap.put("taiQuYiChang", taiQuYiChang);
        dataMap.put("taiQuTongJi", taiQuTongJi);
        dataMap.put("zongHeXianSunLv", zongHeXianSunLv);
        dataMap.put("fuHeQingKuang", fuHeQingKuang);
        dataMap.put("gongDanQingKuang", gongDanQingKuang);

        result.setCode(1);
        result.setData(dataMap);

        return result;
    }
    /**
     * 构造业务清单的数据
     */
    private void buildDetailData() {
        // 1、获取坐标点的数据
        DashPoint query = new DashPoint();
        List<DashPoint> dashPointList = dashPointService.queryList(query);

        // 2、缺陷类型
        List<String> defectTypeList = new ArrayList<>();
        defectTypeList.add("台区异常");
        defectTypeList.add("线损异常");
        defectTypeList.add("无杆号牌");
        defectTypeList.add("无台区命名牌");
        defectTypeList.add("树线矛盾");
        defectTypeList.add("电缆破损");
        defectTypeList.add("鸟窝");
        defectTypeList.add("藤蔓");
        defectTypeList.add("三线搭挂");

        // 缺陷描述
        String[] defectDescs = new String[] { "单相表箱破损", "线损率异常", "电线杆无牌", "无台区铭牌", "树木阻挡电线杆", "电缆破损", "杆上有鸟窝", "藤蔓缠绕杆", "三线搭挂" };
        String[] resolveMethods = new String[] { "更换新电表箱", "检查线损数据", "给电线杆贴牌", "台区命名", "砍伐树木", "更换新电缆", "拆除鸟窝", "砍掉藤蔓", "解除搭线"};

        // 单位
        String units = "衢州";
        // 县公司
        String[] companies = new String[] { "衢州本部", "常山县", "龙游县" };
        // 分局
        String[] subOffices = new String[] { "衢江供电营业部", "常山县营业部", "龙游县营业部" };
        // 供电所
        String[] powerStations = new String[] { "空港新城供电所", "城区供电所", "街道供电所" };
        // 上报人
        String[] reporters = new String[] { "张锋睿", "李广晨", "尹铁锤", "王梅林", "刘丽", "徐湘洪", "陈振", "黄杨", "刘欣怡" };
        // 设备名称
        String[] deviceNames = new String[] { "公共变压器", "配电变压器", "配电箱", "电线杆", "杆塔", "主电站" };
        // 挂载设备
        String[] mountDevices = new String[] { "智能开关", "普通开关", "故障指示器", "高山", "河流", "高铁", "大型光伏" };

        int dataSize = 1000;
        List<DashStats> dashStatsList = new ArrayList<>();
        for (int i = 0; i < dataSize; i++) {
            // 3、坐标点产生随机数范围
            int[] randomList = NumberUtil.generateRandomNumber(0, dashPointList.size(), 1);
            DashPoint point = dashPointList.get(randomList[0]);

            // 单位、县公司、供电所
            int[] areaRandom = NumberUtil.generateRandomNumber(0, 3, 1);
            int area = areaRandom[0];

            String company = companies[area];
            String subOffice = subOffices[area];
            String station = powerStations[area];

            // 4、缺陷类型数据随机数
            int[] defectRandom = NumberUtil.generateRandomNumber(0, defectTypeList.size(), 1);
            int defect = defectRandom[0];
            String defectType = defectTypeList.get(defect);
            String defectDesc = defectDescs[defect];
            String resolveMethod = resolveMethods[defect];

            int[] devices = NumberUtil.generateRandomNumber(0, 6, 1);
            String deviceName = deviceNames[devices[0]];

            // 5、上报人
            String reporter = reporters[defect];
            // 7、挂载设备
            int[] randomMount = NumberUtil.generateRandomNumber(0, mountDevices.length, 1);
            String mountDevice = mountDevices[randomMount[0]];

            DashStats stats = new DashStats();
            stats.setId(ObjectId.get().toString());
            stats.setInspectionDate(new Date());
            stats.setUnits(units);
            stats.setPointId(point.getId());
            stats.setStates(1); // 数据类型，1是设备、2是第二页的用户
            stats.setCountyCompany(company);
            stats.setSuboffice(subOffice);
            stats.setPowerStation(station);
            stats.setDefectType(defectType);
            stats.setDefectDesc(defectDesc);
            stats.setSolveDesc(resolveMethod);
            stats.setReportPerson(reporter);
            stats.setDeviceName(deviceName);
            stats.setMountDevice(mountDevice);

            dashStatsList.add(stats);
        }
        dashStatsService.saveBatch(dashStatsList);

    }

    /**
     * 构建第二页的明细数据
     */
    private void buildUserDetailData() {
        // 1、获取坐标点的数据
        DashPoint query = new DashPoint();
        List<DashPoint> dashPointList = dashPointService.queryList(query);

        // 单位
        String units = "衢州";
        // 县公司
        String company = "衢州本部";
        // 分局
        String subOffice = "衢江供电营业部";
        // 供电所
        String powerStation = "空港新城供电所";
        // 班组
        String[] groups = new String[] { "空港新城供电所服务一班", "空港新城供电所服务一班", "空港新城供电所服务一班", "空港新城供电所服务一班" };

        // 所属线路
        String[] routers = new String[] { "樟莲8268线", "文林8095线", "新城7073线", "空港5697线", "城区3695线", "湖边2367线", "文林7891线", "街区3694线" };

        // 所属网络
        String networkOf = "衢州衢江樟潭分区全旺网格";
        // 户号
        String[] houseNos = new String[] { "7692603490", "7692608852", "7692608853", "7698043360", "7698043368", "7696413368", "7698073960", "7693308859" };
        // 台区
        String[] areas = new String[] { "东家山一台区", "大路口一台区", "大路口二台区", "大路口三台区", "东湖二台区", "东湖一台区", "西湖二台区", "路口二台区" };
        // 故障类型
        List<String> defectTypeList = new ArrayList<>();
        defectTypeList.add("频繁停电用户");
        defectTypeList.add("电压越限");
        defectTypeList.add("电量波动异常");
        defectTypeList.add("疑似窃电用户");
        defectTypeList.add("欠费用户");
        defectTypeList.add("业扩报装");
        defectTypeList.add("故障抢修工单");
        defectTypeList.add("投诉意见工单");
        defectTypeList.add("咨询工单");
        // 挂载设备
        String[] mountDevices = new String[] { "民生重要", "电费敏感", "停电敏感", "设备安全敏感", "光伏用户", "充电桩" };

        String[] userTypes = new String[] { "居民用户", "光伏用户", "充电桩", "非居民" };

        int size = 1000;
        List<DashStats> dashStatsList = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            // 1、获取班组
            int[] groupRandom = NumberUtil.generateRandomNumber(0, 4, 1);
            int group = groupRandom[0];
            String teamGroup = groups[group];

            // 2、获取所属线路
            int[] routerRandom = NumberUtil.generateRandomNumber(0, 8, 1);
            int line = routerRandom[0];
            String router = routers[line];

            // 3、户号
            String houseNo = houseNos[line];

            // 4、台区
            String area = areas[line];

            // 5、故障类型
            int[] defectRandom = NumberUtil.generateRandomNumber(0, 9, 1);
            int di = defectRandom[0];
            String defectType = defectTypeList.get(di);

            // 6、坐标点产生随机数范围
            int[] randomList = NumberUtil.generateRandomNumber(0, dashPointList.size(), 1);
            DashPoint point = dashPointList.get(randomList[0]);

            // 7、挂载设备
            int[] randomMount = NumberUtil.generateRandomNumber(0, mountDevices.length, 1);
            String mountDevice = mountDevices[randomMount[0]];

            int[] randomUser = NumberUtil.generateRandomNumber(0, userTypes.length, 1);
            String userType = userTypes[randomUser[0]];

            DashStats stats = new DashStats();
            stats.setId(ObjectId.get().toString());
            stats.setUnits(units);
            stats.setCountyCompany(company);
            stats.setSuboffice(subOffice);
            stats.setPowerStation(powerStation);
            stats.setNetworkOf(networkOf);
            stats.setStates(2); // 标识第二个页面的数据
            stats.setTeamGroup(teamGroup); // 班组
            stats.setRouterOf(router); // 所属路线
            stats.setHouseholdNo(houseNo); // 户号
            stats.setComments(area); // 台区
            stats.setDefectType(defectType); // 故障类型
            stats.setPointId(point.getId());
            stats.setMountDevice(mountDevice); // 挂载设备
            stats.setUserType(userType); // 用户类型

            dashStatsList.add(stats);
        }

        dashStatsService.saveBatch(dashStatsList);
    }

    /**
     * 线路条数
     * @return
     */
    @RequestMapping("/lineRouter")
    public ResultBean lineRouter(@RequestBody QueryBean queryBean) {
        ResultBean result = new ResultBean();
        Map<String, Integer> data = new HashMap<>();

        String type = queryBean.getType();
        if ("2".equals(type)) {
            int[] lineNum = NumberUtil.generateRandomNumber(3, 10, 1);
            data.put("townNum", lineNum[0]);
            int[] publicNum = NumberUtil.generateRandomNumber(600, 1200, 1);
            data.put("customerNum", publicNum[0]);
            int[] specialNum = NumberUtil.generateRandomNumber(4000, 8000, 1);
            data.put("electricityQuantity", specialNum[0]);
        } else {
            int[] lineNum = NumberUtil.generateRandomNumber(10, 60, 1);
            data.put("lineNum", lineNum[0]);
            int[] publicNum = NumberUtil.generateRandomNumber(300, 600, 1);
            data.put("publicNum", publicNum[0]);
            int[] specialNum = NumberUtil.generateRandomNumber(100, 200, 1);
            data.put("specialNum", specialNum[0]);
        }

        result.setCode(1);
        result.setData(data);

        return result;
    }
}
